<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改账户')" />
    <th:block th:include="include :: bootstrap-fileinput-css"/>
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-account-edit" th:object="${accountAccount}">
            <input name="id" th:field="*{id}" type="hidden">

            <div class="form-group">
                <label class="col-sm-3 control-label is-required">账户分类：</label>
                <div class="col-sm-8">
                    <input name="accountName" th:field="*{accountName}" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">账本介绍：</label>
                <div class="col-sm-8">
                    <textarea name="accountIntroduce" class="form-control">[[*{accountIntroduce}]]</textarea>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">账本状态：</label>
                <div class="col-sm-8">
                    <div class="radio-box" th:each="dict : ${@dict.getType('sys_normal_disable')}">
                        <input type="radio" th:id="${'visible_' + dict.dictCode}" name="visible"   th:value="${dict.dictValue}"  th:field="*{visible}" required>

                        <label th:for="${'visible_' + dict.dictCode}" th:text="${dict.dictLabel}"></label>
                    </div>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">显示顺序：</label>
                <div class="col-sm-8">
                    <input name="orderNum" th:field="*{orderNum}" class="form-control" type="text" required>
                </div>
            </div>

<!--            <div class="form-group">-->
<!--                <label class="col-sm-3 control-label">账户封面/图片：</label>-->
<!--                <div class="col-sm-8">-->
<!--                    <input type="hidden" name="cover" th:field="*{cover}">-->
<!--                    <div id="upload" class="file-loading">-->
<!--                        <input class="form-control file-upload" id="cover" name="file" type="file">-->
<!--                    </div>-->
<!--                </div>-->
<!--            </div>-->

        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: bootstrap-fileinput-js"/>
    <script th:inline="javascript">
        var prefix = ctx + "account/account";
        $("#form-account-edit").validate({
            rules:{
                orderNum:{
                    digits:true
                },
            },
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/edit", $('#form-account-edit').serialize());
            }
        }

        $(".file-upload").each(function (i) {
            var val = $("input[name='" + this.id + "']").val()
            $(this).fileinput({
                'uploadUrl': ctx + 'common/upload',
                initialPreviewAsData: true,
                initialPreview: [val],
                maxFileCount: 1,
                autoReplace: true
            }).on('fileuploaded', function (event, data, previewId, index) {
                $("input[name='" + event.currentTarget.id + "']").val(data.response.url)
            }).on('fileremoved', function (event, id, index) {
                $("input[name='" + event.currentTarget.id + "']").val('')
            })
            $(this).fileinput('_initFileActions');
        });
    </script>
</body>
</html>
